<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserAutoMsgTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_auto_msg', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->char('msg_type', 6)->default(1)->comment('消息类型：text,voice,video,image');
            $table->string('msg_content', 100)->default('')->comment('消息内容');
            $table->tinyInteger('duration')->default(0)->comment('语音或者视频时长（秒）');
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->timestamps();
            $table->index(['user_id', 'msg_type'], 'user_msg_type');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_auto_msg');
    }
}
